package com.zwl.sjzmanagement.controller;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zwl.sjzmanagement.service.TqcService;
import com.zwl.vo.RoomCardContainersVo;
import com.zwl.vo.TqcUpdateNeedsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/tqc")
public class TqcController {

    @Autowired
    private TqcService tqcService;

    @GetMapping("/tqcList")
    public Result tqcList() {
        Map<String, List<TqcUpdateNeedsVo>> tqcUpdateNeedsVos = tqcService.tqcList();

        return Result.ok(tqcUpdateNeedsVos);
    }

//    http://localhost:8001/api/tqc/tqcAddOrUpdate
    @PostMapping("/tqcAddOrUpdate")
    public Result tqcAddOrUpdate(@RequestBody TqcUpdateNeedsVo tqcUpdateNeedsVo) {

        tqcService.tqcAddOrUpdate(tqcUpdateNeedsVo);
        return Result.ok();
    }

//    http://localhost:8001/api/tqc/tqcDelById

    @DeleteMapping("/tqcDelById/{id}")
    public Result tqcDelById(@PathVariable Integer id) {

        tqcService.deleteTqcById(id);

        return Result.ok();

    }

    @PostMapping("/tqcBatchDelById")
    public Result tqcBatchDelById(@RequestBody List<Integer> ids) {

        //根据id判断，相同则执行跟新操作
        tqcService.BatchdeleteTqcById(ids);

        return Result.ok();

    }
    @GetMapping("/getTqcById/{id}")
    public Result getTqcById(@PathVariable Integer id) {

        TqcUpdateNeedsVo tqcUpdateNeedsVo = tqcService.getTqcById(id);
        return Result.ok(tqcUpdateNeedsVo);

    }
}
